Conversation
Yes, sorry about that! Pushed. |
nicoburns
left a comment
There was a problem hiding this comment.
This looks good, but I would like to see this actually running on WASM before merging. In particular, the reason for making this method async is that (AFAIK) polling the surface aquisition future with pollster won't work on WASM (because the future is comes from the JS runtime which can't make progress while our wasm code is blocking), and that we need to spawn it with wasm_bindgen_futures, and then actually await and then handle the result in async manner.
1a69099 to
96c5664
Compare
|
@nicoburns thanks! added a wasm example to Video demo: async-demo.mp4 |
|
@nicoburns got any upcoming time to look at this? thanks! |
nicoburns
left a comment
There was a problem hiding this comment.
So this does make the resume method async, but I don't think it's going to work with the WindowRenderer actually running with a Winit application/window. This is because the async method holds a mutable reference to self, and I think that's going to run into borrow-checking issues.
I think perhaps a channel might by the best way around this. When the async surface creation completes it could send it back to the WindowRenderer through a channel, resolve the future, and then the setup could be completed on the next call to render.
We might also consider having resume take a callback to call once the surface is ready (instead of making it an async function). Then we could keep all the future/async machinery inside the WindowRenderer (the caller would then generate a Winit event (e.g. request_redraw or a custom event) when the callback is called).
|
Let's try and get a WASM example running with Winit-based event loop |

As discussed here DioxusLabs/blitz#160 (comment) the resume method needs to be async for WASM compatibility. This changes the API to an async one.
I recommend looking at the PR with ignore whitespace on https://github.com/DioxusLabs/anyrender/pull/56/changes#diff-d59986e672b1ca00b645e906e7d8018fd74f9ddc5b38f22e94c5da0f5d9dd679?w=1
Some notes:
This requires the callers to implement block_on now. Another option would be to add a resume_sync method that does this, let me know what you prefer.I'm not sure if it was intended but I only see 0.7.0 on main, is 0.8.0 supposed to be pushed?Test plan
Test bunnymark
cargo run -p bunnymarkTest wasm